<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
<%@ include file="/WEB-INF/views/include.inc.jsp" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<!--
“此代码是自动生成，请继续优化注释”
@author 朱祥 024038
@date 2021-01-28 09:20:52
@copyRight: 江苏金恒信息科技股份有限公司
-->
<style>
    a.file-link {
        color: #4d7ad8;
    }
</style>
<form id="pagerForm" method="post" action="${ctx}/fdAttach/list" onsubmit="return navTabAjaxDone(this)">
    <input type="hidden" name="second" value="${param.second}"/>
    <input type="hidden" name="pageNum" value="${page.pageNum}"/>
    <input type="hidden" name="numPerPage" value="${page.numPerPage}"/>
    <input type="hidden" name="orderField" value="${page.orderField}"/>
    <input type="hidden" name="orderDirection" value="${page.orderDirection}"/>
    <input type="hidden" name="keywords" value="${keywords}"/>
    <input type="hidden" name="begindate" value="${attach.begindate}"/>
    <input type="hidden" name="enddate" value="${attach.enddate}"/>
    <input type="hidden" name="strrelativedtype" value="${attach.strrelativedtype}"/>
    <input type="hidden" name="strname" value="${attach.strname}"/>
</form>
<div class="tab-header">
    <form class="layui-form" method="post" action="${ctx}/fdAttach/list" onsubmit="return navTabSearch(this)">
        <input type="hidden" name="second" value="${param.second}"/>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="begindate" value="${attach.begindate}" readonly
                            onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd'})"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">结束时间</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="enddate" value="${attach.enddate}" readonly
                            onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd'})"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">文件名称</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="strname" value="${attach.strname}"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">文件分类</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="strrelativedtype" value="${param.strrelativedtype}"/>
                </div>
            </div>
            <div class="layui-inline" style="float: none">
                <button class="search">查询</button>
            </div>
        </div>
    </form>
</div>
<div class="tab-bars">
    <sec:authorize access="${showAll}||hasAuthority('FdAttach:deleteLogic')">
        <a class="cancel" data-opentab="ajaxTodo" callbackType="" title="确定要删除吗?" href="${ctx}/esBook/cancel?id={slt_uid}">逻辑删除</a>
    </sec:authorize>
    <sec:authorize access="${showAll}||hasAuthority('FdAttach:delete')">
        <a class="delete" data-opentab="ajaxTodo" callbackType="" title="确定要删除吗?" href="${ctx}/esBook/delete?id={slt_uid}">物理删除</a>
    </sec:authorize>
</div>
<div class="tab-content">
    <table class="frog-table">
        <thead>
        <tr>
            <th>序号</th>
            <th>文件名</th>
            <th>文件大小(KB)</th>
            <th>文件类型</th>
            <th>文件业务id</th>
            <th>文件分类</th>
            <c:if test="${empty local}">
                <th>文件描述</th>
            </c:if>
            <th>上传时间</th>
            <th>文件状态</th>
            <th>download</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${list}" var="row" varStatus="status">
            <tr target="slt_uid" rel="${row.id}" id="${row.id}">
                <td>${page.pageBeginCount + status.index + 1}</td>
                <td>
                    <a class="file-link" href="${row.previewUrl}" target="_blank"
                            onclick="return _esPreview(this)">${row.strname}</a>
                </td>
                <td>${row.doublesize}</td>
                <td>${row.strdoctype}</td>
                <td>${row.relativedid}</td>
                <td>${row.strrelativedtype}</td>
                <c:if test="${empty local}">
                    <td>${row.strdesc}</td>
                </c:if>
                <td>${row.createdatetime}</td>
                <td>
                    <c:if test="${row.intisdelete == 1 && row.intisrealdelete==0}">逻辑删除</c:if>
                    <c:if test="${row.intisrealdelete==1}">物理删除</c:if>
                    <c:if test="${row.intisdelete == 0 && row.intisrealdelete==0}">正常</c:if>
                </td>
                <td>
                    <a style="color: #00b7ee; cursor: pointer"
                            onclick="return _es_preDownload('${row.id}', '${row.strname}')">download</a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
<!-- 分页 -->
<%@ include file="/WEB-INF/views/aaSystem/pager/layuiPagerBar.jsp" %>

<script>
    function _esPreview(e) {
        var url = $(e).attr('href');
        if (!url) {
            Dialog.warn('该文件不支持预览');
            return false;
        }
        if (url == 'delete') {
            Dialog.warn('该文件已被删除！');
            return false;
        }
    }

    function _es_preDownload(id, fileName) {
        Ajax.download('${ctx}/fdAttach/download', {id: id}, fileName, function (json) {
        });
        return false;
    }


</script>
